import time
from public.action import *
from public.business import *
from public.testData import *
from public.tools import *

testCase = "DBshop007查看发货状态"

# 调用函数打开指定网址,并且获取函数的返回值,函数返回的是浏览器的对象
driver = openBrowser(urlAdmin)
# 调用函数登录dbshop的后台
DBshopLoginAdmin(driver)
# 调用函数点击销售管理，发货单二级菜单
DBshopEnterMenu2(driver,'销售管理','支付记录')

rootPath = get_pro_rootpath() #获取项目的绝对路径
filePath = rootPath+r'\public\order1.txt' #拼接文件路径
orderNo = readFile(filePath) #读取文件中的订单编号

# 点击订单号对应的链接
driver.find_element_by_xpath("//a[text() = '%s']"%orderNo).click()

s = driver.find_element_by_xpath("//body").text
l = "\("
r = "\)"
order_State = reGetString(s,l,r)

yuqi1 = "已收货"  # 预期值
yuqi2 = "未发货"

if yuqi1 == order_State:
    writeLog("%s 测试通过,状态为已发货" % testCase)
elif yuqi2 == order_State:
    writeLog("测试通过，状态为未发货" %testCase)
else:
    writeLog("%s 测试不通过或其他状态" % testCase)
    getPhoto(driver)
driver.quit()